package org.example.java;


import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.Writer;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;


public class QRCreator {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		String text = "CESAR - Centro de Estudos e Sistemas Avançados do Recife";
		BitMatrix matrix;
		Writer writer = new  QRCodeWriter();
		try {
			matrix = writer.encode(text, BarcodeFormat.QR_CODE, 100, 100);
		} catch (WriterException e) {
			System.out.println("error encoding -> "+e.getMessage());
			return;
		}
		
		System.out.println("Height: "+matrix.height);
		System.out.println("RowSize: "+matrix.rowSize);
		System.out.println("Width: "+matrix.width);
//		System.out.println("toString: "+matrix.toString());
		
		String MyJpgPath = "/home/artur/cesar.png"; //UPDATE WITH YOUR OWN JPG FILE
		
		
		File fileNew = new File(MyJpgPath);
		
	
		
        try {
        	fileNew.createNewFile();
        	MatrixToImageWriter.writeToFile(matrix, "png", fileNew);
		} catch (FileNotFoundException e) {
			System.out.println("FileNotFound");
		} catch (IOException e) {
			System.out.println("IOException");
			e.printStackTrace();
		}
    
		

	}

}
